'use strict'

const FRAME_VALUES = {
  kFrameStart: 0xAA,
  kFrameEnd: 0x55,
  kFrameFixedSize: 23,
  kFrameHeaderSize: 20,
};

const FILEDATA_VALUES = {
  kHeadSize: 0x08,
  kFileTag_CFG: 0x44,
  kDevAttrSize: 37,
  kFileVer: 0x01,
  kFileTag_SCH: 0x54,
  kScheAttrSize: 14,
  kScheFileVer: 0x01
};

const DEVICE_VALUES = {
  MAC_PADDING: '0000000000000000',
  CONTROLLER_STATUS_FIELDS: {
    'v_software': 0x0001,
    'v_sys': 0x0002,
    'v_kernal': 0x0003,
    'v_hardware': 0x0004,
    'mfrs': 0x0005,
    'type': 0x0006,
    'mode': 0x0007,
    'status': 0x0008
  },
  DEVICE_STATUS_FIELDS: {
    'v_software': 0x0001,
    'mfrs': 0x0002,
    'type': 0x0003,
    'volt': 0x1001,
    'amp': 0x1002,
    'power': 0x1003,
    'e_consumption': 0x1004,
    'brightness_min': 0x2001,
    'brightness_max': 0x2002,
    'brightness_poweron': 0x2003,
    'brightness_fault': 0x2004,
    'brightness': 0x2005,
    'switch': 0x2006,
    'transition_duration': 0x2007,
    'brightness_coeffi': 0x2008,
    'total_uptime': 0x3001,
    'status': 0x3002,
    'comm_status': 0x3003,
    'lamp_status': 0x3004,
    'lighting_time': 0x3005
  },
  SWITCH_ENUM: {
    'off': 0,
    'on': 1,
    'invalid': 3 
  }
};

const CMDS = {
  'REGISTER': 0x0001,
  'KEY_UPDATE': 0x0002,
  'SYNC_CLOCK': 0x0003,
  'WORK_MODE': 0x0004,
  'CTRL_STATUS': 0x1001,
  'DIMMNG': 0x2001,
  'SWITCH': 0x2002,
  'DEV_STATUS': 0x3001,
  'FILE_DOWNLOAD': 0x4001,
  'FILE_UPLOAD': 0x4002
};

const EnumValues = {
  'SWITCH': {
    vals: ["off", "on", "placeholder", "invalid"],
    base: 0
  },
  'CONTROLLER_TYPE': {
    vals: ['485'],
    base: 1
  },
  'WORK_MODE': {
    vals: ['Remote', 'Schedule'],
    base: 0
  }
};

const StatusEnums = {
  'CMD_RES_STATUS': {
    0x00: 'Success',
    0x01: 'RegReject',
    0x02: 'ErrTimeFormat',
    0x03: 'NoSchedule',
    0x04: 'AbnormalMode',
    0x05: 'ErrParams',
    0xff: 'Unsuport'
  },
  'CONTROLLER_STATUS': {
    0x00: 'Normal',
    0x01: 'DownlinkAbnormal',
    0x02: 'UpgradeMode',
    0xff: 'Unknown'
  },
  'DIMMING_STATUS': {
    0x00: 'Success',
    0x01: 'Unsuport'
  },
  'SWITCH_STATUS': {
    0x00: 'Success',
    0x01: 'Failed',
    0x03: 'Invalid'
  },  
}

module.exports.FRAME_VALUES = FRAME_VALUES;
module.exports.DEVICE_VALUES = DEVICE_VALUES;
module.exports.FILEDATA_VALUES = FILEDATA_VALUES;
module.exports.CMDS = CMDS;
module.exports.EnumValues = EnumValues;
module.exports.StatusEnums = StatusEnums;